package com.jdk.learn.base;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by ricky
 * on 2018/3/1.
 */
public class ExceptionDemo {

    /**
     * try-with-resources

     */
    public void test() {
        try (FileInputStream input = new FileInputStream("file.txt")) {

            int data = input.read();

            while (data != -1) {

                System.out.print((char) data);

                data = input.read();

            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    }
